package cn.xsw.controller;

import cn.xsw.utils.FileUploadUtils;
import cn.xsw.utils.IResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/file")
@Api(tags = "文件处理接口")
public class FileController extends BaseController {
    @PostMapping("/upload")
    @ApiOperation("文件上传(最大100MB)")
    public IResult uploadFile(MultipartFile file){
        String url=null;
        try{
            return result.success("上传成功").setData(FileUploadUtils.upload(file));
        }catch (Exception e){
            return result.webError("上传失败");
        }
    }
}
